//
//  HZOrderMessageFooterView.m
//  app
//
//  Created by 刘华舟 on 15/8/24.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZOrderMessageFooterView.h"

@interface HZOrderMessageFooterView()<UITextViewDelegate>

@end

@implementation HZOrderMessageFooterView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        self.frame = CGRectOf([UBO_WINDOW fx:UB_LEFT fy:UB_TOP],
                              [UBO_WINDOW fw:UB_WIDTH oh:kHZOrderMessageFooterViewHeight]);
        
        self.backgroundColor = HZ_CLEAR_COLOR;
        
        self.msgTextView = [[UITextView alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kSizeMallViewMargin fy:UB_TOP],
                                                                      [self.ubo fw:UB_WIDTH uw:-2*kSizeMallViewMargin fh:UB_HEIGHT oh:-10])];
        self.msgTextView.textColor = HZ_MALL_TEXT_M_LIGHTGRAY_COLOR;
        self.msgTextView.text = @"给卖家留言";
        self.msgTextView.returnKeyType = UIReturnKeyDone;
        self.msgTextView.delegate = self;
        [self addSubview:self.msgTextView];
        
    }
    return self;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self.msgTextView resignFirstResponder];
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]) {
        [self.msgTextView resignFirstResponder];
        return NO;
    }
    
    return YES;
}

@end
